"use strict";


const Joi = require('joi');
const Result = require("../basics/result");
const CheckUtil = require("../utils/check");
const BasicsCtl = require("../basics/clz/basectl");
const HomeImpl = require("../service/home");

class HomeCtl extends BasicsCtl {

  constructor(context) {
    super(context);
    this.homeImpl = new HomeImpl(this.cloud);
  }


  /**
   * 修改用户
   */
  async updateAppId() {
    const rule = {
      userId: Joi.number().integer().required(),
      appId: Joi.string().required()
    }
    CheckUtil.validate(rule, this.params);
    return await this.homeImpl.editAppId(this.params);
  }


  /**
   * 查询店铺
   */
  async findTeamp() {
    let { sourceMiniAppId } = this.params;
    console.log("sourceMiniAppId", sourceMiniAppId);
    return await this.homeImpl.findTeamp(sourceMiniAppId);

  }

  /**
   * 小部件初始化
   */
  async initTeamp() {
    let { miniappId, appVersion, instanceWidgetId, authToken } = this.params;
    let data = { entity_id: instanceWidgetId, template_id: miniappId, template_version: appVersion, authToken };
    console.log('initTeamp:', data);
    return await this.homeImpl.initTeamp(data);

  }

}
module.exports = HomeCtl;